<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Wechat H5 Pay</title>
</head>
<body>
<h1>Wechat H5 Pay</h1>
<script>
    function onBridgeReady() {
        WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "appId": "wx48458e0f0203a48c",     //公众号名称，由商户传入
                    "timeStamp": "1471488226",         //时间戳，自1970年以来的秒数
                    "nonceStr": "rjlxcwql0g4dl9pqe0cox46b32zf297f", //随机串
                    "package": "prepay_id=wx201608181043470fe5d8774c0397591862",
                    "signType": "MD5",         //微信签名方式：
                    "paySign": "2B9887750AA4A3871A9D5A393311B7BD" //微信签名
                },
                function (res) {
                    if (res.err_msg == "get_brand_wcpay_request：ok") {
                    }     // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
                }
        );
    }
    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }
</script>
</body>
</html>